package framework;

import java.lang.reflect.Field;

import org.openems.entity.Key;

public class ID {

	public ID() {
		super();
	}

	public void buildID(String applicationName) {
		Object object = this;
		for (Field field : object.getClass().getFields()) {
			if (field.getType().equals(Key.class)) {
				String fieldName = field.getName();
				
				try {
					field.set(object, Key.class.newInstance());
					Key element = (Key)field.get(object);
					element.setValue(fieldName);
					element.setApplication(applicationName);
				} catch (SecurityException e) {
					e.printStackTrace();
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InstantiationException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

}